home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr42 / vocshow2.zip / SB_SAMPL.LIB < prev    next >
Text File  |  1993-06-08  |  2KB  |  62 lines

  1. -- Copyright 1992 by Tom Moran.  May be used by anyone for any purpose.
  2.  
  3. package SB_Samples is
  4.  
  5.   -- max DMA transfer block is limited to 64K by hardware and may be
  6.   -- further restricted by software, eg 386^MAX limits to 16K unless
  7.   -- you specifically tell it to allow bigger transfers (DMA= option)
  8.   -- so we'll make a safe maximum block length
  9.   Max_Block_Length:constant:=16383;
  10.  
  11.   -- Unpacked and Packed (4 bits/sample) are the most used formats,
  12.   -- and indeed the only ones I understand.  They are accordingly
  13.   -- given special names - not Packed1 and Packed2 as one might expect
  14.   -- for maximum consistency
  15.  
  16.   subtype Sound_Indices is integer range 0 .. Max_Block_Length-1;
  17.  
  18.   type Unpacked_Sound_Samples is range 0 .. 255;
  19.   for Unpacked_Sound_Samples'Size use 8;
  20.   type Unpacked_Sounds is array (Sound_Indices range <>)
  21.     of Unpacked_Sound_Samples;
  22.  
  23. -- Note: the 'correct' description of 4 bit packed data is:
  24. --
  25. -- type packed_sound_samples is record
  26. --   sign      : integer range 0 .. 1;
  27. --   magnitude : integer range 0 .. 7;
  28. -- end record;
  29. --  for packed_sound_samples'size use 4;
  30. --  for packed_sound_samples use record
  31. --    sign      at 0 range 3 .. 3;     -- 4th bit from right
  32. --    magnitude at 0 range 0 .. 2;     -- rightmost 3 bits
  33. --  end record;
  34. --
  35. -- type packed_sounds is array(integer range <>) of packed_sound_samples;
  36. -- pragma pack(packed_sounds);
  37. --
  38. -- but the method that runs faster with my particular compiler is:
  39.  
  40.   type Packed_Sound_Nibbles is range 0 .. 15;
  41.   for Packed_Sound_Nibbles'Size use 4;
  42.  
  43.   type Packed_Sound_Pairs is range 0 .. 255;
  44.   for Packed_Sound_Pairs'Size use 8;
  45.  
  46.   type Packed_Sounds is array (Sound_Indices range <>)
  47.     of Packed_Sound_Pairs;
  48.  
  49.   type Packed_Sound_Triples is range 0 .. 255;
  50.   for Packed_Sound_Triples'Size use 8;
  51.  
  52.   type Packed3_Sounds is array (Sound_Indices range <>)
  53.     of Packed_Sound_Triples;
  54.  
  55.   type Packed_Sound_Quadruples is range 0 .. 255;
  56.   for Packed_Sound_Quadruples'Size use 8;
  57.  
  58.   type Packed4_Sounds is array (Sound_Indices range <>)
  59.     of Packed_Sound_Quadruples;
  60.  
  61. end SB_Samples;
  62.